<html>
    <head>
        <meta charset="utf-8">
        <title>加载WMS图层</title>
        <!-- leaflet的css样式 -->
        <link rel="stylesheet" href="../lib/leaflet.css" />
        <!-- leaflet的js库 -->
        <script type="text/javascript" src="../lib/leaflet-src.js"></script>
        <!-- 地图容器样式 -->
        <style>
            #mapDiv{
                width: 100%;
                height: 100%;
            }
        </style>

        <script type="text/javascript">
            var map = null; 

            function init(){

                map = L.map("mapDiv", { 
                    center: [0,0],
                    zoom: 2,
                });

                // 1. 添加osm图层为底图
                L.tileLayer( 
                    'http://{s}.tile.osm.org/{z}/{x}/{y}.png'
                ).addTo(map);

                // 2.添加WMS图层
                var wms_url = "http://sedac.ciesin.columbia.edu/geoserver/wms";

                L.tileLayer.wms(wms_url, {                      // wms服务地址
                    layers: 'cartographic:national-boundaries', // wms图层
                    format: 'image/png',                        // wms图片格式
                    transparent: true,                          // 背景透明
                }).addTo(map);
}
        </script>
            
    </head>
    <body onload="init()">
        <!--地图的容器-->
        <div id="mapDiv"></div>
    </body>
</html>



